š” Paper Reference & Attribution: This article is derived from an in-depth study, engineering analysis, and architectural interpretation of the Microsoft research paper From Local to Global: A Graph RAG Approach to Query-Focused Summarization (arXiv:2404.16130).
Microsoft GraphRAG treats an entire input directory as a unified corpus rather than isolated silos. Its core design philosophy is: load all documents together, chunk uniformly, and build a unified knowledge graph, enabling seamless cross-document entity linkage and knowledge synthesis. Multiple heterogeneous files are merged into a single documents DataFrame for downstream processing.
The GraphRAG Indexing Pipeline is architected as a sequential workflow composed of modular phases:
MERMAID
This pipeline transforms raw unstructured documents into a queryable, hierarchical knowledge graph.
Core Component: The graphrag-input package provides an abstract base class InputReader, yielding documents via an asynchronous iterator (__aiter__) from local or cloud storage.
Multi-Format Processing Matrix:
| File Format | Processing Strategy |
|---|---|
| TXT | Each .txt file is ingested as an individual document |
| CSV | Each CSV row is parsed as a distinct document; multiple CSVs are merged into a unified DataFrame |
| JSON / JSONL | Parsed into structured document objects; JSONL processed line-by-line |
| Parquet | Read natively using PyArrow / Polars |
Ingestion Steps:
file_pattern regex (default: .*\.txt$).title metadata attribute.documents DataFrame.Text chunking is a rule-based preprocessing step that does not invoke LLMs. The create_base_text_units workflow employs the graphrag-chunking engine to split documents into discrete "Text Units" (Chunks).
Configuration Parameters (configured in settings.yaml):
| Parameter | Description | Default Value |
|---|---|---|
chunk_size | Maximum token limit per text unit | 1200 Tokens |
chunk_overlap | Token overlap between adjacent text units | 100-200 Tokens |
The chunking engine splits on sentence boundaries (such as periods and punctuation marks), accumulating sentences up to the chunk_size limit. All documents across the entire directory are chunked in a unified pass, establishing the groundwork for cross-document entity and relationship extraction.
This phase represents the most compute- and LLM-intensive step:
(entity, relation, entity) triplets along with descriptions and contextual evidence from each chunk.title). Even if an entity is referenced in different documents under different phrasings, it converges onto a single, unified entity node.Generates dense vector embeddings for entities, relationships, text chunks, and community summaries to power hybrid and semantic search queries.
GraphRAG utilizes the Factory Pattern for deep customization across subsystems:
Initialize a standard GraphRAG project structure using the CLI:
bashgraphrag init [--root PATH]
This interactive command scaffolds configuration files and default prompt templates.
text<project_root>/ āāā .env # Environment variables (API keys, endpoints) āāā settings.yaml # Primary pipeline configuration āāā input/ # Raw document ingestion folder ā āāā doc1.txt ā āāā doc2.txt ā āāā dataset.csv ā āāā subfolder/ # Supports recursive subdirectories ā āāā doc3.txt āāā prompts/ # LLM prompt templates ā āāā entity_extraction.txt ā āāā community_report.txt ā āāā ... āāā output/ # GraphRAG index artifacts (Parquet format) āāā entities.parquet āāā relationships.parquet āāā communities.parquet āāā ...
settings.yaml)yamlinput: type: file # Storage backend: file | memory | blob | cosmosdb file_pattern: ".*\\.(txt|csv|json)" # File matching regex base_dir: "input" # Ingestion source directory chunking: size: 1200 # Chunk token budget overlap: 100 # Overlap token count embedding: model: "text-embedding-3-small" vector_store: type: "lancedb"
When new documents need to be added to an existing knowledge graph, use the graphrag update workflow:
Note: While incremental updates work effectively for additive documents, full index reconstruction remains the most consistent approach when dealing with extensive document deletions or modifications.